//
//  SKGoodsStorage.m
//  loveKangaroo
//
//  Created by SeeKool on 15/3/4.
//  Copyright (c) 2015年 SeeKool Inc. All rights reserved.
//

#import "SKGoodsStorageView.h"
#import "SKGoodCell.h"

@interface SKGoodsStorageView ()<UITableViewDataSource,UITableViewDelegate>

@end
@implementation SKGoodsStorageView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        UIButton *creatNew = [UIButton buttonWithType:UIButtonTypeCustom];
        [creatNew setTitle:@"增加一个新的商品" forState:UIControlStateNormal];
        [creatNew setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        creatNew.frame = CGRectMake(0, 0, ScreenWidth, 30);
        [self addSubview:creatNew];
        
        self.backgroundColor = [UIColor redColor];
        UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 30, ScreenWidth, 300) style:UITableViewStyleGrouped];
        tableView.dataSource = self;
        tableView.delegate = self;
        [self addSubview:tableView];
        
        tableView.sectionHeaderHeight = 0;
        tableView.sectionFooterHeight = 0;

    }
    return self;
}
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (0 == section) {
        return 1;
    }else if (1 == section){
        return 2;
    }else if (2 == section){
        return 3;
    }
    return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *ID = @"SKGoodsStorageViewCellIdentifier";
    SKGoodCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[SKGoodCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    cell.backgroundColor = [UIColor redColor];
    return cell;
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 120;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}

@end
